#include "stackeddialog.h"
#include "childwidgeta.h"
#include "childwidgetb.h"
#include <QPushButton>
#include <QStackedLayout>


StackedDialog::StackedDialog(QWidget *parent) :
    MyDialogBase(parent)
{

    ChildWidgetA* a=new ChildWidgetA(this);
    ChildWidgetB* b=new ChildWidgetB(this);

    QStackedLayout *stackedLayout = new QStackedLayout;
    stackedLayout->addWidget(a);
    stackedLayout->addWidget(b);
    mStackedLayout=stackedLayout;

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(stackedLayout);

    QPushButton *button=new QPushButton(this);
    button->setText("Switch");
    button->setGeometry(0,0,60,30);
    mainLayout->addWidget(button);
    connect(button,SIGNAL(clicked()),this,SLOT(buttonClicked()));

    setLayout(mainLayout);
}

void StackedDialog::buttonClicked()
{
    static int index=0;
    if(index==0)
        index=1;
    else
        index=0;
    mStackedLayout->setCurrentIndex(index);
}
